package com.treasure.mall.zbqmallapi.websocket;

import com.treasure.mall.biz.remote.live.TencentIMService;
import com.treasure.mall.biz.service.core.live.LiveSessionService;
import com.treasure.mall.biz.service.core.user.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.web.socket.server.standard.ServerEndpointExporter;

/**
 *
 * <p>
 * +---------------------------------------------------------
 * * @package: com.treasure.mall.zbqmallapi.config
 * * @author: guomw (guomwchen@foxmail.com)
 * * @date: 2020/9/3 10:18 上午
 * * @since: V1.0.0
 * +---------------------------------------------------------
 * 注意：本内容仅限于内部传阅，禁止外泄以及用于其他的商业目的
 * 
 */
@Slf4j
@Configuration
@EnableAspectJAutoProxy(proxyTargetClass = true)
public class WebSocketConfig {
    /**
     * ServerEndpointExporter 作用
     * <p>
     * 这个Bean会自动注册使用@ServerEndpoint注解声明的websocket endpoint
     *
     * @return
     */
    @Bean
    public ServerEndpointExporter serverEndpointExporter() {
        return new ServerEndpointExporter();
    }

    @Autowired
    public void setLiveSessionService(LiveSessionService sessionService) {
        LiveWebSocketServer.liveSessionService = sessionService;
    }

    @Autowired
    public void setUserService(UserService userService) {
        LiveWebSocketServer.userService = userService;
    }

    @Autowired
    public void setTencentIMService(TencentIMService imService) {
        LiveWebSocketServer.imService = imService;
    }
}
